package com.atguigu.gmall.list.api;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.list.service.SkuEsService;
import com.atguigu.gmall.model.list.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 钟涛
 * @version 1.0
 * @description: TODO
 * @date 2021/12/18 11:51
 */
@RestController
@RequestMapping("/api/es/sku")
public class SkuEsController {
    @Autowired
    private SkuEsService skuEsService;
    @PostMapping("/up")
    public Result upSkuInfo(@RequestBody Goods goods){
        skuEsService.upSku(goods);
        return Result.ok();
    }

    @GetMapping("/down/{skuId}")
    public Result downSkuInfo(@PathVariable("skuId") Long skuId){
        skuEsService.downSku(skuId);
        return Result.ok();
    }

    @GetMapping("/incrementHotScore/hot/{skuId}")
    public Result incrementHotScore(@PathVariable("skuId") Long skuId,@RequestParam("hotScore") Long hotScore){
        skuEsService.incrementHotScore(skuId,hotScore);
        return Result.ok();
    }
}
